<!--
@license
(C) Copyright Nuxeo Corp. (http://nuxeo.com/)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
  <head>
    <title>nuxeo-search demo</title>
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes" />
    <script src="/components/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
    <script type="module">
      import '@polymer/polymer/polymer-legacy.js';
      import '../nuxeo-connection.js';
      import '../nuxeo-search.js';
    </script>
  </head>

  <style>
    html,
    body {
      height: 100%;
      margin: 0;
      background-color: #e5e5e5;
      font-family: 'RobotoDraft', sans-serif;
    }

    .container {
      width: 80%;
      margin: 50px auto;
    }

    .card {
      display: block;
      position: relative;
      background-color: white;
      padding: 10px;
      margin-bottom: 20px;
      width: 100%;
    }

    .propName {
      display: inline-block;
      font-weight: bold;
      width: 125px;
      margin-right: 0;
    }

    .prop:not(:first-child) {
      margin-top: 12px;
    }
  </style>
  <body>
    <dom-bind>
      <template>
        <nuxeo-connection
          id="nx"
          url="http://localhost:8080/nuxeo"
          username="Administrator"
          password="Administrator"
        ></nuxeo-connection>
        <nuxeo-search auto searches="{{searches}}"></nuxeo-search>
        <div class="container" class="layout vertical center">
          <template is="dom-repeat" items="{{searches}}">
            <div class="card">
              <div class="prop">
                <label class="propName">id:</label>
                <label class="propValue">[[item.id]]</label>
              </div>
              <div class="prop">
                <label class="propName">title:</label>
                <label class="propValue">[[item.title]]</label>
              </div>
              <template is="dom-if" if="[[item.pageProviderName]]">
                <div class="prop">
                  <label class="propName">page provider:</label>
                  <label class="propValue">[[item.pageProviderName]]</label>
                </div>
              </template>
              <template is="dom-if" if="[[item.query]]">
                <div class="prop">
                  <label class="propName">query:</label>
                  <label class="propValue">[[item.query]]</label>
                </div>
              </template>
              <template is="dom-if" if="[[item.queryParams]]">
                <div class="prop">
                  <label class="propName">params:</label>
                  <label class="propValue">[[item.queryParams]]</label>
                </div>
              </template>
            </div>
          </template>
        </div>
      </template>
    </dom-bind>
  </body>
</html>
